#include<stdio.h>

typedef int _Type;

_Type binary_serching(_Type arr[], _Type target, int hight, int low){
    int mid;
    while (hight >= low){
        mid = (hight + low) / 2;
        printf("\t[%d-%d] arr[%d] = %d; %d\n", hight, low, mid, arr[mid], target);
        if (arr[mid] < target)
            low = mid + 1;
        else if (arr[mid] > target)
            hight = mid -1;
        else
            return arr[mid]; 
    }
    return -1;
}

int main(){
    // 测试样例
    _Type arr[] = {1, 3, 4, 6, 8, 12, 22};
    _Type target1 = 4, target2 = 20;
    printf("%d\n", binary_serching(arr, target1, 6, 0));
    printf("%d\n", binary_serching(arr, target2, 6, 0));
    return 0;
}